package com.parent.elasticsearch.old.esentitys;

import com.parent.elasticsearch.old.result.HitsNew;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author yan
 * @date 2023/7/20 0020 22:39
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class HitsNew1<T> implements Serializable {
    private static final long serialVersionUID = 1972181754716332416L;
    /**
     * 索引
     */
    private String _index;
    /**
     * 类型
     */
    private String _type;
    /**
     * 返回实体主键
     */
    private String _id;
    /**
     * 查询分数
     */
    private Double _score;
    /**
     * 返回实体
     */
    private T _source;

    public static HitsNew toResult(HitsNew1 hitsNew) {
        String _index = hitsNew.get_index();
        String _type = hitsNew.get_type();
        String _id = hitsNew.get_id();
        Double _score = hitsNew.get_score();
        Object _source = hitsNew.get_source();

       HitsNew hitsNew1 = new HitsNew(_index,_type,_id,_score,_source);
        return hitsNew1;
    }

}